import request from '@/utils/request'
// import qs from 'qs'

// 动态路由

// BGP获取展示路由
export function getBgpRoute (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getBgpRoute',
    method: 'post',
    data
  })
}

// BGP获取协议信息
export function getBgpInfo (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getBgpInfo',
    method: 'post',
    data
  })
}

// Bgp编辑导入信息
export function editBgpInfo (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/editBgpInfo',
    method: 'post',
    data
  })
}

// Bgp添加路由聚合
export function addBgpAggregatedRoute (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addBgpAggregatedRoute',
    method: 'post',
    data
  })
}

// Bgp删除路由聚合
export function delBgpAggregatedRoute (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delBgpAggregatedRoute',
    method: 'post',
    data
  })
}

// Bgp添加路由
export function addBgp (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addBgp',
    method: 'post',
    data
  })
}

// Bgp删除路由
export function delBgp (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delBgp',
    method: 'post',
    data
  })
}

// Bgp添加对等体
export function addBgpPeer (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addBgpPeer',
    method: 'post',
    data
  })
}

// Bgp删除对等体
export function delBgpPeer (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delBgpPeer',
    method: 'post',
    data
  })
}

// Bgp添加发布路由
export function addBgpPublishRoute (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addBgpPublishRoute',
    method: 'post',
    data
  })
}

// Bgp删除发布路由
export function delBgpPublishRoute (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delBgpPublishRoute',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }
